package com.ljx.controller;

import com.ljx.pojo.Order;
import com.ljx.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @version V1.0
 * @author: Ljxpa
 * @date: 2020/02/24 19:56
 * @description:
 */
@RestController
@RequestMapping("/order")
public class OrderController {

	@Autowired
	private RestTemplate restTemplate;


	@GetMapping("/{id}")
	public Order getOrderInfo(@PathVariable String id){
		Order order= new Order(id,"小米手机"+id,"1001",null);
		String url = "http://localhost:8080/user/1";
		User user = restTemplate.getForObject(url, User.class);
		order.setUserName(user.getName());
		return order;
	}
}
